home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / mlib / draw / commands.cpp next >
Text File  |  1994-03-13  |  6KB  |  217 lines

  1. #include <io.h>
  2. #include <mio.h>
  3. #include <mgr.h>
  4. #include <mmulle.h>
  5. #include <mevent.h>
  6. #include <mwin.h>
  7. #include <mparent.h>
  8. #include <mcontrol.h>
  9. #include <stdarg.h>
  10. #include "draw.h"
  11.  
  12. /********************************************/
  13.  WORD           NewPixmap (...)
  14. /********************************************/
  15. {
  16. Canvas * DrawSpace;
  17.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  18.     DrawSpace->pixmap->Clear();
  19.     CreateEvent (REFRESH_WINDOW, 0, NULL, 0L, CANVAS_HANDLE);
  20.     return (EVENT_USED);
  21. }
  22.  
  23. /********************************************/
  24.  WORD           LoadPixmap (...)
  25. /********************************************/
  26. {
  27. Canvas * DrawSpace;
  28.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  29.     AskFilename (DrawSpace->filename);
  30.     if (access (DrawSpace->filename, 0) == 0)
  31.        DrawSpace->pixmap->Load (DrawSpace->filename);
  32.     DrawSpace->ResizeWorld (DrawSpace->pixmap->GetLength(), DrawSpace->pixmap->GetWidth());
  33.     return (EVENT_USED);
  34. }
  35.  
  36. /********************************************/
  37.  WORD           SavePixmap (...)
  38. /********************************************/
  39. {
  40. Canvas * DrawSpace;
  41.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  42.     AskFilename (DrawSpace->filename);
  43.     DrawSpace->pixmap->Save (DrawSpace->filename);
  44.     return (EVENT_USED);
  45. }
  46.  
  47. /********************************************/
  48.  WORD           ResizePixmap (...)
  49. /********************************************/
  50. {
  51. Canvas * DrawSpace;
  52. WORD length, width;
  53.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  54.     length = DrawSpace->pixmap->GetLength();
  55.     width = DrawSpace->pixmap->GetWidth();
  56.     AskSize (&length, &width);
  57.     DrawSpace->pixmap->Redefine (length, width);
  58.     DrawSpace->ResizeWorld (length, width);
  59.     return (EVENT_USED);
  60. }
  61.  
  62. /********************************************/
  63.  WORD          ScrollPixmapUp (...)
  64. /********************************************/
  65. {
  66. Canvas * DrawSpace;
  67.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  68.     DrawSpace->Scroll (Up);
  69.     return (EVENT_USED);
  70. }
  71.  
  72. /********************************************/
  73.  WORD          ScrollPixmapDown (...)
  74. /********************************************/
  75. {
  76. Canvas * DrawSpace;
  77.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  78.     DrawSpace->Scroll (Down);
  79.     return (EVENT_USED);
  80. }
  81.  
  82. /********************************************/
  83.  WORD          ScrollPixmapLeft (...)
  84. /********************************************/
  85. {
  86. Canvas * DrawSpace;
  87.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  88.     DrawSpace->Scroll (Left);
  89.     return (EVENT_USED);
  90. }
  91.  
  92. /********************************************/
  93.  WORD          ScrollPixmapRight (...)
  94. /********************************************/
  95. {
  96. Canvas * DrawSpace;
  97.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  98.     DrawSpace->Scroll (Right);
  99.     return (EVENT_USED);
  100. }
  101.  
  102. /********************************************/
  103.  WORD            QuitApp (...)
  104. /********************************************/
  105. {
  106.     return (SHELL_QUIT);
  107. }
  108.  
  109. /********************************************/
  110.  WORD           LoadDraw (...)
  111. /********************************************/
  112. {
  113. MULLE datafile;
  114. Canvas * DrawSpace;
  115.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  116.     DrawSpace->mode = DRAWING;
  117.  
  118.     datafile.SetMainFile ("draw.dat");
  119.     mouse.Load ("draw.dat", datafile.GetOffset ("arrow.cur"));
  120.     return (EVENT_USED);
  121. }
  122.  
  123. /********************************************/
  124.  WORD           LoadFill (...)
  125. /********************************************/
  126. {
  127. MULLE datafile;
  128. Canvas * DrawSpace;
  129.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  130.     DrawSpace->mode = FILLING;
  131.  
  132.     datafile.SetMainFile ("draw.dat");
  133.     mouse.Load ("draw.dat", datafile.GetOffset ("fill.cur"));
  134.     return (EVENT_USED);
  135. }
  136.  
  137. /********************************************/
  138.  WORD           LoadErase (...)
  139. /********************************************/
  140. {
  141. MULLE datafile;
  142. Canvas * DrawSpace;
  143.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  144.     DrawSpace->mode = ERASING;
  145.  
  146.     datafile.SetMainFile ("draw.dat");
  147.     mouse.Load ("draw.dat", datafile.GetOffset ("erase.cur"));
  148.     return (EVENT_USED);
  149. }
  150.  
  151. /********************************************/
  152.  WORD           LoadMagnify (...)
  153. /********************************************/
  154. {
  155. MULLE datafile;
  156. Canvas * DrawSpace;
  157.     DrawSpace = (Canvas*) root.Find (CANVAS_HANDLE);
  158.     DrawSpace->mode = MAGNIFYING;
  159.  
  160.     datafile.SetMainFile ("draw.dat");
  161.     mouse.Load ("draw.dat", datafile.GetOffset ("magnify.cur"));
  162.     return (EVENT_USED);
  163. }
  164.  
  165. /********************************************/
  166.  void            AskFilename
  167. /********************************************/
  168. (BYTE * Buffer)
  169. {
  170. RECT PromptBox (100,70,240,90);
  171. RECT TypingBox (105,73,200,85);
  172. RECT QuitBox (205,73,235,85);
  173. MParent PromptBase (PromptBox, 0x100F, HROOT);
  174. MGetInput Typer (TypingBox, "Filename: ", 13, 0x1010, 0x100F);
  175. MButton OkButton (QuitBox, "Ok", 0x1011, 0x100F);
  176.  
  177.     Typer.SetBuffer (Buffer);
  178.     OkButton.SetUserHandler (QuitApp);
  179.     FinishSetup (0x100F);
  180.     PromptBase.Realize();
  181.     PromptBase.Run();
  182. }
  183.  
  184. /********************************************/
  185.  void              AskSize
  186. /********************************************/
  187. (WORD * length, WORD * width)
  188. {
  189. RECT PromptBox (100,70,220,110);
  190. RECT TypingBox1 (105,73,170,85);
  191. RECT TypingBox2 (105,93,170,105);
  192. RECT QuitBox (180,73,215,105);
  193. MParent PromptBase (PromptBox, 0x100F, HROOT);
  194. MGetInput LengthTyper (TypingBox1, "Length: ", 4, 0x1010, 0x100F);
  195. MGetInput WidthTyper (TypingBox2, "Width: ", 4, 0x1011, 0x100F);
  196. MButton OkButton (QuitBox, "Ok", 0x1012, 0x100F);
  197. BYTE LengthString[5];
  198. BYTE WidthString[5];
  199. int NewLength, NewWidth;
  200.  
  201.     LengthTyper.SetBuffer (LengthString);
  202.     WidthTyper.SetBuffer (WidthString);
  203.     OkButton.SetUserHandler (QuitApp);
  204.  
  205.     FinishSetup (0x100F);
  206.     PromptBase.Realize();
  207.     PromptBase.Run();
  208.  
  209.     LengthTyper.FlushToBuffer();
  210.     WidthTyper.FlushToBuffer();
  211.  
  212.     if ((NewLength = atoi (LengthString)) > 0 && NewLength < MAXX)
  213.        *length = NewLength;
  214.     if ((NewWidth = atoi (WidthString)) > 0 && NewWidth < MAXY)
  215.        *width = NewWidth;
  216. }
  217.